| API Documentation |  |

- MAIN PAGE
- NAMESPACES
- CLASSES

Component.h
1 // Component.h
3 //
5
6 namespace nkWinUi
7 {
11 class Component : public nkExport::Exportable
12 {
13 public :
14
22 Component (System* system) noexcept ;
26 virtual ~Component () ;
27
28 // Getters
32 Layout* getLayout () const ;
36 Theme* getTheme () const ;
40 Font* getFont () const ;
44 nkMaths::Point getPositionInParent () const ;
48 nkMaths::Point getPositionInScreen () const ;
52 float getWidth () const ;
56 float getHeight () const ;
60 nkMaths::Rectangle getAreaInParent () const ;
64 nkMaths::Rectangle getAreaInScreen () const ;
68 virtual nkMaths::Point getBorderExtents () const ;
75 virtual float getBorderExtent (BORDER_KIND border) const ;
79 virtual float getLayoutAllowedWidth () const ;
83 virtual float getLayoutAllowedHeight () const ;
87 virtual float getLayoutAllowedOffsetX () const ;
91 virtual float getLayoutAllowedOffsetY () const ;
95 bool isInitialized () const ;
99 System* getSystem () const ;
103 Component* getParentComponent () const ;
107 COMPONENT_TYPE getComponentType () const ;
111 nkMemory::StringView getComponentName () const ;
115 bool getVisibility () const ;
119 virtual nkMemory::StringView getLabel () const ;
123 void* getData () const ;
127 bool isEnabled () const ;
131 bool isForegroundWindow () const ;
135 virtual unsigned int getZDepth () const ;
139 bool getVisibleOnLoad () const ;
143 std::function<bool (Component*)> getCloseCallback () const ;
147 std::function<void (Component*, bool)> getVisibilityCallback () const ;
151 std::function<void (Component*, const ClickEventData&)> getClickCallback () const ;
155 std::function<void (Component*, const WheelEventData&)> getWheelCallback () const ;
159 std::function<void (Component*, const KeyEventData&)> getKeyCallback () const ;
160
161 // Setters
171 virtual Layout* setLayout (LAYOUT_TYPE layoutType) ;
179 virtual void setTheme (Theme* theme) ;
185 virtual void setFont (Font* font) ;
191 virtual void setPositionInParent (nkMaths::Point position) ;
197 virtual void setPositionInScreen (nkMaths::Point position) ;
204 virtual void setSize (float width, float height) ;
210 virtual void setWidth (float width) ;
216 virtual void setHeight (float height) ;
223 void setMinSize (float width, float height) ;
230 void setMaxSize (float width, float height) ;
236 void setRatio (float widthOverHeight) ;
242 virtual void setAreaInParent (const nkMaths::Rectangle& area) ;
248 virtual void setAreaInScreen (const nkMaths::Rectangle& area) ;
255 virtual void setParentComponent (Component* parent, bool makeItVisible = true) ;
262 virtual void setLabel (nkMemory::StringView label) ;
270 void setComponentName (nkMemory::StringView name) ;
276 virtual void setVisibility (bool value) ;
284 void setData (void* data) ;
292 void setEnabled (bool value) ;
299 void setVisibleOnLoad (bool value) ;
306 void setCloseCallback (std::function<bool (Component* caller)> callback) ;
312 void setVisibilityCallback (std::function<void (Component* caller, bool visibility)> callback) ;
318 void setClickCallback (std::function<void (Component* caller, const ClickEventData& eventData)> callback) ;
324 void setWheelCallback (std::function<void (Component* caller, const WheelEventData& eventData)> callback) ;
330 void setKeyCallback (std::function<void (Component* caller, const KeyEventData& eventData)> callback) ;
331
338 void addChild (Component* child, bool makeItVisible = true) ;
344 void removeChild (Component* child) ;
352 void removeChild (unsigned int index) ;
359 Component* getChild (unsigned int index) ;
368 unsigned int getChildIndex (Component* child) ;
372 void unloadWithChildren () ;
376 void loadWithChildren () ;
380 void updateZDepth () ;
381
385 void bringToForeground () ;
389 void focusWindow () ;
390
397 nkMaths::Point getCoordRelativeFromAbsolute (nkMaths::Point absCoords) ;
404 nkMaths::Point getCoordAbsoluteFromRelative (nkMaths::Point relCoords) ;
405
410 virtual void load () = 0 ;
415 virtual void unload () = 0 ;
420 void reload () ;
421
425 virtual void updateWindow () ;
426
442 nkImages::Image paintToImage (bool withFrame = false) ;
443
451 void simulateEvent (const InputDescriptor& inputDescription) ;
455 virtual void onSized () ;
456
462 virtual void exportClassToTree (nkExport::Node* rootNode) override ;
469 virtual void exportIntrospection (nkExport::Node* rootNode) ;
475 virtual void importClassFromTree (nkExport::Node* rootNode) override ;
476 } ;
477 }
nkWinUi::Component::isEnabled
bool isEnabled() const
nkWinUi::Component::updateWindow
virtual void updateWindow()
nkWinUi::ClickEventData
Data holder for a click event.
Definition: ClickEventData.h:12
nkWinUi::Component::setRatio
void setRatio(float widthOverHeight)
nkWinUi::Component::getPositionInScreen
nkMaths::Point getPositionInScreen() const
nkWinUi::Component::getSystem
System * getSystem() const
nkWinUi::KeyEventData
Data holder for a key event.
Definition: KeyEventData.h:12
nkWinUi::Component::importClassFromTree
virtual void importClassFromTree(nkExport::Node *rootNode) override
nkWinUi::Component::getCoordAbsoluteFromRelative
nkMaths::Point getCoordAbsoluteFromRelative(nkMaths::Point relCoords)
nkWinUi::Component::onSized
virtual void onSized()
nkWinUi::Component::getHeight
float getHeight() const
nkWinUi::Component::setWidth
virtual void setWidth(float width)
nkWinUi::Component::getCoordRelativeFromAbsolute
nkMaths::Point getCoordRelativeFromAbsolute(nkMaths::Point absCoords)
nkWinUi::Component::getCloseCallback
std::function< bool(Component *)> getCloseCallback() const
nkWinUi::Component::setClickCallback
void setClickCallback(std::function< void(Component *caller, const ClickEventData &eventData)> callback)
nkWinUi::LAYOUT_TYPE
LAYOUT_TYPE
Defines the type of layout available.
Definition: LayoutType.h:12
nkWinUi::Component::setData
void setData(void *data)
nkWinUi::Component::setPositionInParent
virtual void setPositionInParent(nkMaths::Point position)
nkWinUi::Component::getWidth
float getWidth() const
nkWinUi::Component::getTheme
Theme * getTheme() const
nkExport::Exportable
An interface to define objects that can be exported using this component.
Definition: Exportable.h:15
nkWinUi::Component::setVisibility
virtual void setVisibility(bool value)
nkWinUi::Component::getLayout
Layout * getLayout() const
nkWinUi::Component::removeChild
void removeChild(unsigned int index)
nkWinUi::Component::getAreaInScreen
nkMaths::Rectangle getAreaInScreen() const
nkWinUi::Component::setMinSize
void setMinSize(float width, float height)
nkWinUi::Layout
Represents a layout to organize children of a component.
Definition: Layout.h:12
nkWinUi::Font
Offers an interface to work with fonts.
Definition: Font.h:14
nkWinUi::Component::paintToImage
nkImages::Image paintToImage(bool withFrame=false)
nkWinUi::Component::setMaxSize
void setMaxSize(float width, float height)
nkWinUi::Component::reload
void reload()
nkWinUi::Component::setAreaInParent
virtual void setAreaInParent(const nkMaths::Rectangle &area)
nkWinUi::Component::simulateEvent
void simulateEvent(const InputDescriptor &inputDescription)
nkWinUi::Component::setLayout
virtual Layout * setLayout(LAYOUT_TYPE layoutType)
nkWinUi::Component::getAreaInParent
nkMaths::Rectangle getAreaInParent() const
nkWinUi::Component
Base class for any graphical component.
Definition: Component.h:12
nkWinUi::Component::bringToForeground
void bringToForeground()
nkWinUi::Component::unloadWithChildren
void unloadWithChildren()
nkWinUi::System
The main system of the component.
Definition: System.h:18
nkWinUi::Component::setHeight
virtual void setHeight(float height)
nkWinUi::Component::getZDepth
virtual unsigned int getZDepth() const
nkWinUi::Component::setEnabled
void setEnabled(bool value)
nkWinUi::Component::setFont
virtual void setFont(Font *font)
nkWinUi::Component::setTheme
virtual void setTheme(Theme *theme)
nkWinUi::Component::isInitialized
bool isInitialized() const
nkWinUi::Component::setVisibleOnLoad
void setVisibleOnLoad(bool value)
nkWinUi::Component::exportClassToTree
virtual void exportClassToTree(nkExport::Node *rootNode) override
nkWinUi::Component::setParentComponent
virtual void setParentComponent(Component *parent, bool makeItVisible=true)
nkWinUi::Component::getKeyCallback
std::function< void(Component *, const KeyEventData &)> getKeyCallback() const
nkWinUi::Component::getParentComponent
Component * getParentComponent() const
nkWinUi::Component::getVisibilityCallback
std::function< void(Component *, bool)> getVisibilityCallback() const
nkExport::Node
A node in the tree structure representing the data to export / import.
Definition: Node.h:42
nkWinUi::COMPONENT_TYPE
COMPONENT_TYPE
Available component types.
Definition: ComponentType.h:12
nkWinUi::Component::setAreaInScreen
virtual void setAreaInScreen(const nkMaths::Rectangle &area)
nkWinUi::Component::getBorderExtents
virtual nkMaths::Point getBorderExtents() const
nkWinUi::Component::getComponentType
COMPONENT_TYPE getComponentType() const
nkWinUi::Component::getLabel
virtual nkMemory::StringView getLabel() const
nkWinUi::Component::setPositionInScreen
virtual void setPositionInScreen(nkMaths::Point position)
nkMaths::Point
Represents a 2D Point.
Definition: Point.h:12
nkWinUi::Component::getData
void * getData() const
nkWinUi::Component::setWheelCallback
void setWheelCallback(std::function< void(Component *caller, const WheelEventData &eventData)> callback)
nkWinUi::Component::setCloseCallback
void setCloseCallback(std::function< bool(Component *caller)> callback)
nkWinUi::Component::getLayoutAllowedOffsetX
virtual float getLayoutAllowedOffsetX() const
nkWinUi::Component::getChild
Component * getChild(unsigned int index)
nkWinUi::Component::getLayoutAllowedHeight
virtual float getLayoutAllowedHeight() const
nkWinUi::Component::focusWindow
void focusWindow()
nkMemory::StringView
Class holding information about a string, with no ownership over the data.
Definition: StringView.h:22
nkWinUi::Component::setKeyCallback
void setKeyCallback(std::function< void(Component *caller, const KeyEventData &eventData)> callback)
nkWinUi::Component::isForegroundWindow
bool isForegroundWindow() const
nkWinUi::Component::setSize
virtual void setSize(float width, float height)
nkWinUi::Component::Component
Component(System *system) noexcept
nkWinUi::Component::loadWithChildren
void loadWithChildren()
nkWinUi::Theme
A theme used to style the windows in the component.
Definition: Theme.h:44
nkWinUi::Component::getVisibility
bool getVisibility() const
nkWinUi::Component::getWheelCallback
std::function< void(Component *, const WheelEventData &)> getWheelCallback() const
nkWinUi::InputDescriptor
Describes an input event.
Definition: InputDescriptor.h:14
nkWinUi::Component::exportIntrospection
virtual void exportIntrospection(nkExport::Node *rootNode)
nkWinUi::Component::load
virtual void load()=0
nkWinUi::Component::getComponentName
nkMemory::StringView getComponentName() const
nkWinUi::BORDER_KIND
BORDER_KIND
Lists borders kind around components.
Definition: BorderKind.h:12
nkMaths::Rectangle
Represents a 2D rectangle.
Definition: Rectangle.h:12
nkWinUi::Component::setComponentName
void setComponentName(nkMemory::StringView name)
nkWinUi::Component::getBorderExtent
virtual float getBorderExtent(BORDER_KIND border) const
nkWinUi::Component::getPositionInParent
nkMaths::Point getPositionInParent() const
nkWinUi::WheelEventData
Data holder for a wheel event.
Definition: WheelEventData.h:12
nkWinUi::Component::~Component
virtual ~Component()
nkWinUi::Component::removeChild
void removeChild(Component *child)
nkWinUi::Component::getVisibleOnLoad
bool getVisibleOnLoad() const
nkWinUi::Component::updateZDepth
void updateZDepth()
nkWinUi::Component::getLayoutAllowedWidth
virtual float getLayoutAllowedWidth() const
nkWinUi
Encompasses all API of component NilkinsWinUi.
Definition: Clipboard.h:7
nkWinUi::Component::unload
virtual void unload()=0
nkWinUi::Component::setLabel
virtual void setLabel(nkMemory::StringView label)
nkWinUi::Component::getLayoutAllowedOffsetY
virtual float getLayoutAllowedOffsetY() const
nkWinUi::Component::addChild
void addChild(Component *child, bool makeItVisible=true)
nkWinUi::Component::getFont
Font * getFont() const
nkImages::Image
Holds all information required for an image, with ownership over the data.
Definition: Image.h:14
nkWinUi::Component::getClickCallback
std::function< void(Component *, const ClickEventData &)> getClickCallback() const
nkWinUi::Component::getChildIndex
unsigned int getChildIndex(Component *child)
nkWinUi::Component::setVisibilityCallback
void setVisibilityCallback(std::function< void(Component *caller, bool visibility)> callback)